<!DOCTYPE html>
<title>Test HTMLVideoElement's prefixed fullscreen API.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<video></video>
<script>
async_test(function(t) {
    var video = document.querySelector("video");
    assert_true(video.webkitSupportsFullscreen);
    assert_false(video.webkitDisplayingFullscreen);
    video.src = "content/test.ogv";

    video.onloadeddata = t.step_func(function() {
        assert_true(video.webkitSupportsFullscreen);
        assert_false(video.webkitDisplayingFullscreen);
        video.webkitEnterFullscreen();
        video.onwebkitfullscreenerror = t.step_func(function() {
            assert_true(video.webkitSupportsFullscreen);
            assert_false(video.webkitDisplayingFullscreen);

            document.onclick = t.step_func(function() {
                video.webkitEnterFullscreen();
                video.onwebkitfullscreenchange = t.step_func(function() {
                    assert_true(video.webkitSupportsFullscreen);
                    assert_true(video.webkitDisplayingFullscreen);
                    video.webkitExitFullscreen();
                    video.onwebkitfullscreenchange = t.step_func_done(function() {
                        assert_true(video.webkitSupportsFullscreen);
                        assert_false(video.webkitDisplayingFullscreen);
                    });
                });
            });

            eventSender.mouseDown();
            eventSender.mouseUp();
        });
    });
});
</script>